package mysql;

import java.util.Properties;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class Mysql_access {

    public static String DB_CONN_STRING = "";
    public static String DRIVER_CLASS_NAME = "";
    public static String USER_NAME = "";
    public static String PASSWORD = "";

    public static boolean isConfigured(){
        if (DB_CONN_STRING.length() < 2) return false;
        else    
            return true;
    }
    
    public static void tryGetNewerAccess() {

        Properties prop = new Properties();
        InputStream input = null;
        try {
            input = new FileInputStream("config.properties");
            /* Wczytywanie pliku z konfiguracja */
            prop.load(input);
            DB_CONN_STRING = prop.getProperty("DB_CONN_STRING");
            DRIVER_CLASS_NAME = prop.getProperty("DRIVER_CLASS_NAME");
            USER_NAME = prop.getProperty("USER_NAME");
            PASSWORD = prop.getProperty("PASSWORD");
           
        } catch (IOException ex) {
            ex.printStackTrace();
        } finally {
            if (input != null) {
                try {
                    input.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

}
